﻿cmake_minimum_required(VERSION 3.20)

project(OpenVisaDocument)
find_program(QDOC qdoc)
find_program(QHELP_GENERATOR qhelpgenerator)
include("${Qt5_CONFIG}")

set(AUTOMOC ON)
set(AUTOUIC ON)
set(AUTORCC ON)

if(NOT QDOC)
message("requires qdoc")
return()
endif()

find_package(QT NAMES Qt6 Qt5 REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets REQUIRED)
add_custom_target(document COMMAND ${CMAKE_COMMAND} -E rm -r -f ${PROJECT_SOURCE_DIR}/doc
 COMMAND ${CMAKE_COMMAND} -E env "QT_VER=${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}"
 ${CMAKE_COMMAND} -E env "QT_VERSION=${QT_VERSION}"
 ${CMAKE_COMMAND} -E env "QT_VERSION_TAG=${QT_VERSION_MAJOR}${QT_VERSION_MINOR}${QT_VERSION_PATCH}"
 ${CMAKE_COMMAND} -E env "BUILDDIR=."
 ${CMAKE_COMMAND} -E env "QT_INSTALL_DOCS=\"$ENV{QTDIR}/../../Docs/Qt-${QT_VERSION}\""
 qdoc ${CMAKE_CURRENT_LIST_DIR}/config/openvisa.qdocconf -D Q_OS_WIN -D QT_CORE_LIB -D QT_GUI_LIB -D QT_WIDGETS_LIB
 COMMAND
 qhelpgenerator ${PROJECT_SOURCE_DIR}/doc/openvisa.qhp -o ${PROJECT_SOURCE_DIR}/doc/openvisa.qch
 SOURCES
 "config/openvisa.qdocconf"
 "src/classes.qdoc"
 "src/index.qdoc"
 COMMAND assistant -register ${PROJECT_SOURCE_DIR}/doc/openvisa.qch)

# get_cmake_property(_variableNames VARIABLES)
#foreach (_variableName ${_variableNames})
#    message(STATUS "${_variableName}=${${_variableName}}")
#endforeach()
